// pages/detail/detail.js
const fetch = require('../../utils/fetch.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        shopDetails: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        fetch(`shops/${options.item}`).then(res => {
            this.setData({
                shopDetails: res.data
            })
            wx.setNavigationBarTitle({ title: res.data.name })
        })
    },

    previewHandle: function(e) {
        wx.previewImage({
            current: e.target.dataset.url,
            urls: this.data.shopDetails.images
        })
    }
})